package com.example.studygo.handle;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.*;

/**
 * @author 路老师
 * @date 2025/8/13
 * 无精神，不编程！无乐趣，不编程！
 * “调试：与bug共舞的艺术。”
 */
@Component
public class FillDateHandler implements MetaObjectHandler {
    /**
     * 当插入数据时自动调用
     * @param metaObject
     */
    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject, "createTime", ()->new Date(), Date.class);
    }
    /**
     * 修改数据时自动调佣该方法
     * @param metaObject
     */
    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictUpdateFill(metaObject, "updateTime", ()->new Date(), Date.class);
    }
}
